import {createApp, reactive} from 'vue'
import Message from './src/index.vue'

const msg = reactive({
    title: '',
    type: 'success',
    duration: 2000
})

export const message = {
    success(title) {
        const $Message = createApp(Message, {msg}).mount(document.createElement('div'))
        msg.title = title
        msg.type = 'success'
        document.body.appendChild($Message.$el)
    },
    warning(title) {
        const $Message = createApp(Message, {msg}).mount(document.createElement('div'))
        msg.title = title
        msg.type = 'warning'
        document.body.appendChild($Message.$el)
    },
    info(title) {
        const $Message = createApp(Message, {msg}).mount(document.createElement('div'))
        msg.title = title
        msg.type = 'info'
        document.body.appendChild($Message.$el)
    },
    error(title) {
        const $Message = createApp(Message, {msg}).mount(document.createElement('div'))
        msg.title = title
        msg.type = 'error'
        document.body.appendChild($Message.$el)
    }
}
